Home
Q&A
Education
Technology
Credit
General
Health
Insurance
Questions
Ask a Question
Extract data from a JSON file
Home
Education
Extract data from a JSON file
asked
May 14, 2022
in
Education
by
JackTerrance
My code is about bookStore with list of books. I need to extract all data(books) from a JSON file and put them in a cardView. My code is working there I did not got any error but the data is not extracting or printing in a webpage. There is an index.html that structured the page and I wrote also cardView code in it. index.js class document.addEventListener("DOMContentLoaded", async () => { await handleLoadListValues(); }); async function getBooks(searchOptions) { let url = '/api/books/'; if (searchOptions) { url = `${url}?search-options=${searchOptions}`; } const response = await fetch(url); return response.json(); } async function handleLoadListValues(searchOptions) { try { const books = await getBooks(); document.querySelector('#books-table').innerHTML = `
${title}
This is the shorthand for flex-grow, flex-shrink and
${books.map(book => bookToHTMLRow(book)).join('')}
`; } catch (e) { console.log(e); } } function bookToHTMLRow(book) { return `
`; } JSON file data Example { "_id": 1, "title": "Unlocking Android", "isbn": "1933988673", "pageCount": 416, "publishedDate": { "$date": "2009-04-01T00:00:00.000-0700" }, "thumbnailUrl": "
https://s3.amazonaws.com/AKIAJC5RLADLUMVRPFDQ.book-thumb-images/ableson.jpg",
"shortDescription": "Unlocking Android: A Developer's Guide provides concise...", "longDescription": "Android is an open source mobile phone... ", "status": "PUBLISH", "authors": [ "W. Frank Ableson", "Charlie Collins", "Robi Sen" ], "categories": [ "Open Source", "Mobile", "java" ] }, What is wrong with my code? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)
javascripthtmlapi
1
Answer
0
votes
answered
May 14, 2022
by
JackTerrance
json from mocky io i test with in case not working mock another one with the same json and change the url : [ { "id": 777, "thumbnailUrl": "
https://parismatch.be/app/uploads/2018/04/Macaca_nigra_self-portrait_large-e1524567086123-1100x715.jpg",
"title": "balabla", "shortDescription": "jijiji" } ] i tried with fetech then I changed to axios, I corrected some html tags like:
To
${book.title}
document.addEventListener("DOMContentLoaded", async() => { await handleLoadListValues(); }); async function getBooks(searchOptions) { const books = await axios.get('
http://www.mocky.io/v2/5c94e68a3600006c15941d7e'
) return books.data } function bookToHTMLRow(book) { return `
${book.title}
${book.shortDescription}
`; } async function handleLoadListValues(searchOptions) { try { const books = await getBooks(true); document.querySelector('#books-table').innerHTML = `${books.map(book => bookToHTMLRow(book)).join('')}`; } catch (e) { //console.log(e); } }
Run code snippetExpand snippet
Related questions
0
votes
Q: Correct Json Path to extract the data
i have a json structure like that, where i would like to take from the json path the "id", but ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Apr 7, 2022
in
Education
by
JackTerrance
jsonstructurejsonpath
0
votes
Q: Parse JSON record to extract key and value and put into Map in java
I have one column in my table which will store data in string format the sample data is {"pre- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Feb 27, 2022
in
Education
by
JackTerrance
javajson
0
votes
Q: How to extract Windows user profile SIDs from registry into text file?
I have a task coming up where I have to manually enter an HKEY_USER key value and string value for ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Jun 3, 2022
in
Education
by
JackTerrance
batch-file
0
votes
Q: extract text from <p>...</p> tag or directly from an HTML file
I have an HTML page that contains some filenames that i want to download from a webserver. I need ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Jan 13, 2022
in
Education
by
JackTerrance
interview-question-answer
0
votes
Q: How can we write JSON data to a file?
How can we write JSON data to a file?...
asked
Jan 11, 2021
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
0
votes
Q: _________ extract a subset of rows from a data frame based on logical conditions.
_________ extract a subset of rows from a data frame based on logical conditions. (a) rename (b) filter ( ... Analysis of R Programming Select the correct answer from above options...
asked
Feb 9, 2022
in
Education
by
JackTerrance
r
programming
profiling
simulation
and
data
analysis
wrangling
0
votes
Q: How to extract open graph meta data from a webpage using UIPath RPA?
Learning RPA with UIPath. Happily extracting onscreen data from a website, processing it, using it, etc. However, ... this stage :/ Select the correct answer from above options...
asked
Feb 1, 2022
in
Education
by
JackTerrance
rpa
uipath
0
votes
Q: Download copy, extract data from an open system done fraudulently is treated as _________
Download copy, extract data from an open system done fraudulently is treated as _________ (a) cyber-warfare (b) ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked
Nov 4, 2021
in
Education
by
JackTerrance
essential-cyber-security-interview-questions
cyber-security-interview-questions-answers
cyber-security-multiple-choice-questions
cyber-security-mcq-with-answers
cyber-security-mcq
core-cyber-security-questions
0
votes
Q: _________ is the sum of all the possible points in software or system where unauthorized users can enter as well as extract data from the system.
_________ is the sum of all the possible points in software or system where unauthorized users can enter as well as ... questions and answers pdf, mcq on Cyber Security pdf,...
asked
Nov 3, 2021
in
Education
by
JackTerrance
essential-cyber-security-interview-questions
cyber-security-interview-questions-answers
cyber-security-multiple-choice-questions
cyber-security-mcq-with-answers
cyber-security-mcq
core-cyber-security-questions
0
votes
Q: Which of the following is used to extract data from HTML code of websites?
Which of the following is used to extract data from HTML code of websites? (a) Webscraping (b) ... questions and answers pdf, Data Science interview questions for beginners...
asked
Oct 29, 2021
in
Education
by
JackTerrance
essential-data
science-interview-questions
data
science-interview-questions-answers
science-multiple-choice-questions
science-mcq-with-answers
science-mcq
core-data
science-questions
0
votes
Q: ____________ is the NiFi element that is utilized to monitor incoming data, pull data from outside sources, publish data to outside sources, and route, transform, or extract data from FlowFiles.
____________ is the NiFi element that is utilized to monitor incoming data, pull data from outside sources, publish data ... the options (2)Connection (3)Processor (4)Relationship...
asked
Apr 18, 2021
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
0
votes
Q: how to bind class name from a json file using Angular [ngClass]
I have a json file contains a icons object like this: "icons" : { "logo" : "fa fa-caret-down ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
Apr 9, 2022
in
Education
by
JackTerrance
angular
0
votes
Q: Which of the following function programmatically extract parts of XML file?
Which of the following function programmatically extract parts of XML file? (a) XmlSApply (b) XmlApply (c) ... and answers pdf, Data Science interview questions for beginners...
asked
Oct 29, 2021
in
Education
by
JackTerrance
essential-data
science-interview-questions
data
science-interview-questions-answers
science-multiple-choice-questions
science-mcq-with-answers
science-mcq
core-data
science-questions
0
votes
Q: What is the benefit of Tableau Extract file over the live connection?t
What is the benefit of Tableau Extract file over the live connection?...
asked
Oct 29, 2020
in
Technology
by
JackTerrance
interview-question-answer
technology-questions-answers
0
votes
Q: How to DeserializeObject from json where data model exist in Entity Framework?
I have an incoming json object that represents the data pulled from a database structure. I would like to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked
May 24, 2022
in
Education
by
JackTerrance
c#jsonentity-frameworkattributes
...